package com.zhixing.web.api.controller;

import com.zhixing.web.api.annotation.Log;
import com.zhixing.web.api.dataobject.entity.Menu;
import com.zhixing.web.api.dataobject.untils.ResultVoUtil;
import com.zhixing.web.api.dataobject.vo.ResultVO;
import com.zhixing.web.common.enums.IsCloseEnum;
import com.zhixing.web.service.MenuService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author dzh
 * @version 1.0.0.05020
 * <p>project: d-blog</p>
 * <p>created time: 2022/05/09 15:32</p>
 * <p>describe: 菜单信息API</p>
 * <p>remarks: </p>
 **/
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Resource
    private MenuService menuService;

    /**
     * <p>描述：获取菜单</p>
     *
     * @author dzh
     * @return List<Menu> 菜单信息列表
     * <p>时间：2022/5/9 16:07</p>
     * <p>说明1：</p>
     * <p>说明2：</p>
     **/
    @PostMapping("/list")
    @Log("获取菜单")
    public ResultVO<Menu> getMenuList() {

        Menu menu = new Menu();

        menu.setIsClose(IsCloseEnum.IS_SHOW_NO.getCode());

        return ResultVoUtil.success(menuService.getMenuList(menu));
    }

    /**
     * <p>描述：获取菜单（分页）</p>
     *
     * @author dzh
     * @param pageNum 当前页码
     * @param pageSize 每页数量
     * @return List<Menu> 菜单信息列表
     * <p>时间：2023/3/10 14:39</p>
     * <p>说明1：</p>
     * <p>说明2：</p>
     **/
    @GetMapping("/page/list")
    @Log("获取菜单(分页)")
    public ResultVO<Menu> getMenuListByPage(int pageNum, int pageSize) {

        Menu menu = new Menu();

        menu.setIsClose(IsCloseEnum.IS_SHOW_NO.getCode());

        return ResultVoUtil.success(menuService.getMenuListByPage(menu, pageNum, pageSize));
    }
}
